import javax.swing.*;

import java.awt.*;

/**
 * @author lys
 * 用户入口页面
 */

public class UserInterface {
    private static UserInterface instance;

    public JFrame user = new JFrame("图书管理系统");
    private JTabbedPane jTabbedPane = new JTabbedPane();
    private JPanel jPanel = new JPanel();
    private JLabel jLabel = new JLabel("欢迎登录图书管理系统");
    private JLabel jLabel2 = new JLabel("WELCOME TO LIBRARY SYSTEM");
    private Font font1 = new Font("华文彩云",Font.BOLD,60);
    private Font font2 = new Font("华文彩云",Font.BOLD,40);

    private JPanel jPanel2 = new JPanel();
    private JLabel jLabel3 = new JLabel("lalala");
    private JPanel jPanel3 = new JPanel();
    private JPanel jPanel4 = new JPanel();

    private UserInterface() {
        user.setSize(1200,800);
        user.setLocationRelativeTo(null);
//        jPanel.setBounds(0,0,1200,800);
        jLabel.setBounds(280,200,1200,200);
        jLabel.setFont(font1);
        jLabel.setForeground(Color.white);
        jLabel2.setBounds(300,300,1200,200);
        jLabel2.setFont(font2);
        jLabel2.setForeground(Color.white);

        Icon img = new ImageIcon(UserInterface.class.getResource("img/3.jpg"));
        JLabel label = new JLabel(img);
        label.setBounds(0,0,1200,800);

        jPanel.add(jLabel);
        jPanel.add(jLabel2);
        jPanel.setLayout(null);
        jPanel.setOpaque(false);
        jPanel.add(label);

        Search search = Search.getInstance();
        BorrowAndReturn borrowAndReturn = BorrowAndReturn.getInstance();

        jTabbedPane.addTab("主页",jPanel);
        jTabbedPane.addTab("查询图书",search.jLayeredPane);
        jTabbedPane.addTab("借还图书", borrowAndReturn.jLayeredPane);
        jTabbedPane.addTab("账户管理",Profile.getInstance().jPanel2);


        user.setContentPane(jTabbedPane);
//        user.add(label);
        user.setVisible(true);
        user.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


    }

    public static UserInterface getInstance() {
        if (instance == null ) {
            instance = new UserInterface();
        }
        return instance;
    }

    public static void removeInstance(){
        instance = null;
    }
}
